package cn.nbt.busManage.model.dto;

import cn.nbt.busManage.model.entity.News;
import cn.nbt.busManage.model.vo.NewsVo;
import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.persistence.Column;
import lombok.Data;

import java.sql.Date;
import java.time.LocalDateTime;

@Data
public class NewsDto {
    private Integer id;
    private String title;
    private String author;
    private String content;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;
    public NewsDto(News news){
        this.id = news.getId();
        this.title = news.getTitle();
        this.author = news.getAuthor();
        this.content = news.getContent();
        this.createTime =news.getCreateTime();
        this.updateTime=news.getUpdateTime();

    }
    public NewsDto(NewsVo newsVo){
        this.id = newsVo.getId();
        this.title = newsVo.getTitle();
        this.author = newsVo.getAuthor();
        this.content = newsVo.getContent();
        this.createTime = newsVo.getCreateTime();
        this.updateTime = newsVo.getUpdateTime();
    }
}
